{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="sheng" lay-search="" class="layui-input search" id="province"  lay-filter="province">
                                <option value="">---- 请选择省 ----</option>
                                {foreach name="province" item="vo"}
                                <option value="{$vo.district_id}" >{$vo.district}</option>
                                {/foreach}
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="shi" lay-search="" class="layui-input search"  id="city"  lay-filter="city">
                                <option value="">---- 请选择市 ----</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="qu" lay-search="" class="layui-input search"  id="district"  lay-filter="district">
                                <option value="">---- 请选择区 ----</option>
                            </select>
                        </div>

                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="bsc_status" class="layui-input">
                                <option value="" >不限状态</option>
                                <option value="1">待审核</option>
                                <option value="2">审核通过</option>
                                <option value="3">审核拒绝</option>
                            </select>
                        </div>

                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="apply_role" class="layui-input">
                                <option value="" >不限角色</option>
                                <option value="3">区域加盟商</option>
                                <option value="4">县级运营商</option>
                                <option value="5">市级分公司</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <input type="text"  name="start_time" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="注册开始时间" />
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <input type="text"  name="end_time" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="注册结束时间" />
                        </div>

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" class="layui-input search" name="user_keyword" placeholder="申请用户姓名/手机号"/>
                        </div>

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" class="layui-input search" name="keyword" placeholder="联系人姓名/手机号"/>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12">
                    <div class="input-group" >

                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                        <i class="fa fa-wrench"></i> 导出数据 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                        <li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-external-link"></i> 导出选中数据</a></li>
                        <li><a  href="javascript:;" class="layuiBtn" data-type="excelAllNoSelect"><i class="fa fa-external-link"></i> 全部导出</a></li>
                        </ul>

                    </div>
                </div>
                <!--搜索框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>

                    <!--操作模板-->
                    <script type="text/html" id="bsc_status">
                    {{# if(d.bsc_status == 1){ }}
                    待审核
                    {{# } }}
                    {{# if(d.bsc_status == 2){ }}
                    <span style="color: green">审核通过</span>
                    {{# } }}
                    {{# if(d.bsc_status == 3){ }}
                    <span style="color: red">审核拒绝</span>
                    {{# } }}
                    </script>

                    <script type="text/html" id="apply_role">
                    {{# if(d.bsc_role == 3){ }}
                    区域加盟商
                    {{# } }}
                    {{# if(d.bsc_role == 4){ }}
                    县级运营商
                    {{# } }}
                    {{# if(d.bsc_role == 5){ }}
                    市级分公司
                    {{# } }}
                    </script>

                    <script type="text/html" id="opeBar">
                        {{# if(d.bsc_status == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.bsc_id}}','{:url('applyAllow')}','确定通过吗?')" class="btn btn-primary btn-xs m-r-xs" title="通过">通过</a>
                        <a href="javascript:;" onclick="wk.layer_show('审核拒绝','{:url('applyRefuse')}?bsc_id={{d.bsc_id}}')" class="btn btn-danger btn-xs m-r-xs" title="拒绝">拒绝</a>
                        {{# } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Bocheck/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 300]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type: 'checkbox', fixed: 'left'},
                  {type:'numbers', width: 80, title: '序号'}
//                , {field: 'bsc_id', width: 80, title: 'ID', align: 'center'}
                , {field: 'user_username', width: 120, title: '申请用户名称', align: 'center'}
                , {field: 'user_phone', width: 120, title: '申请用户手机', align: 'center'}
                , {field: 'bsc_user_name', width: 120, title: '联系人姓名', align: 'center'}
                , {field: 'bsc_user_phone', width: 120, title: '联系人手机', align: 'center'}
                , {field: 'bsc_role', width: 90, title: '角色', align: 'center',templet: '#apply_role'}
                , {field: 'bsc_status', width: 90, title: '状态', align: 'center',templet: '#bsc_status'}
                , {field: 'sheng', width: 100, title: '省', align: 'center'}
                , {field: 'shi', width: 100, title: '市', align: 'center'}
                , {field: 'qu', width: 100, title: '区', align: 'center'}
                , {field: 'bsc_address', width: 100, title: '详细地址', align: 'center'}
                , {field: 'bsc_shop_name', width: 100, title: '店铺名称', align: 'center'}
                , {field: 'bsc_time', width: 160, title: '申请时间', align: 'center'}
                , {field: 'bsc_check_time', width: 160, title: '审核时间', align: 'center'}
                , {field: 'bsc_refuse_reason', width: 160, title: '拒绝原因', align: 'center'}
                , {fixed: 'right', width:140, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.aaasss').viewer({
                    url: 'data-original'
                });
            }
        });
        //批量操作
        var $ = layui.$, active = {
            //批量导出订单
            excelAll:function () {
                wk.excelAll(getIds(), $('.layui-input').serialize(), "{:url('outExcel')}");
            },
            //全部导出
            excelAllNoSelect:function () {
                wk.excelAllNoSelect(-1, $('.layui-input').serialize(), "{:url('outExcel')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['bsc_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>